﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SICOIA.UserControls.Mensajes
{
    public partial class DoAfterPostback : System.Web.UI.UserControl
    {
        public string DoAfterPostbackJavaScript { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            Page.ClientScript.RegisterStartupScript(
                this.GetType(),
                "DoAfterPostbackJavaScriptEngine",
                @"            
                var prm = Sys.WebForms.PageRequestManager.getInstance();  
                prm.add_endRequest(function(s, e) {  
                    $('[id$=_DoAfterPostbackJavaScriptHiddenField]').each(doPostbackJS); 
                }); 
                
                function doPostbackJS(i){                    
                    eval(this.value);                    
                }
            
            ", true);
        }

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            DoAfterPostbackJavaScriptHiddenField.Value = DoAfterPostbackJavaScript;
        }

    }
}